﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class People : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void gridPeople_RowCommand(object sender, GridViewCommandEventArgs e)
    {
      if (e.CommandName=="cmdEdit")
      {
        int row = Convert.ToInt32(e.CommandArgument);
        string id = gridPeople.DataKeys[row].Value.ToString();
        Response.Redirect("People-Edit.aspx?id=" + id);
      }
    }
    protected void bnRemoveSearch_Click(object sender, EventArgs e)
    {
      Response.Redirect("People.aspx");
    }
    protected void bnSearch_Click(object sender, EventArgs e)
    {
      string search = txtSearch.Text.Trim();
      if (search.Length > 0)
      {
        bnRemoveSearch.Visible = true;
        sdsPeople.FilterExpression = string.Format(@"
          isnull(first_name,'') + ' ' +
          isnull(last_name,'') + 
          isnull(email,'')
          like
          '%{0}%'
          ",Conn.Sanitise(search));
      }
    }
}
